package fr.umlv.m2.jee.spij.persistence.education;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Entity Question who contain questions and answer.
 *
 * @author Lounes Akroune
 * @author Aurelien Scelles
 */
@Entity
@Table(name = "QUE_QUESTION")
public class Question implements Serializable {
    /**
     * Primary key.
     */
    @Id
    @Column(name = "QUE_ID", nullable = false, unique = true, updatable = false)
    @GeneratedValue(strategy = GenerationType.AUTO)
    private long id;

    /**
     * Link between questions and quiz.
     */
    @ManyToMany(cascade = {CascadeType.ALL}, mappedBy = "questions")
    private List<Quiz> quiz = new ArrayList<Quiz>();

    /**
     * The question.
     */
    @Column(name = "QUE_ASK_QUESTION", nullable = false, unique = true)
    private String question;

    /**
     * The answer.
     */
    @Column(name = "QUE_RESPONCE")
    private String responce;

    /**
     * Setter of Id.
     *
     * @param id
     */
    public void setId(long id) {
        this.id = id;
    }

    /**
     * Getter of Id.
     *
     * @return primary key
     */
    public long getId() {
        return id;
    }

    /**
     * Setter of question.
     *
     * @param question
     */
    public void setQuestion(String question) {
        this.question = question;
    }

    /**
     * Getter of question.
     *
     * @return the question
     */
    public String getQuestion() {
        return question;
    }

    /**
     * Setter of responce.
     *
     * @param responce
     */
    public void setResponce(String responce) {
        this.responce = responce;
    }

    /**
     * Getter of responce.
     *
     * @return the answer
     */
    public String getResponce() {
        return responce;
    }

    /**
     * Setter of quiz.
     *
     * @param quiz
     */
    public void setQuiz(List<Quiz> quiz) {
        this.quiz = quiz;
    }

    /**
     * Getter of quiz.
     *
     * @return list of linked quiz
     */
    public List<Quiz> getQuiz() {
        return quiz;
    }

}
